home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 May / CMCD0504.ISO / Software / Freeware / Programare / gdiplusdelphi / demos / Using Graphics Containers / The State of a Graphics Object / Quality Settings / GDITEST71.dpr
Encoding:
Text File  |  2003-10-15  |  2.4 KB  |  91 lines

  1. program GDITEST71;
  2.  
  3. uses
  4.   Windows,
  5.   Messages,
  6.   SysUtils,
  7.   GDIPAPI,
  8.   GDIPOBJ;
  9.  
  10. Procedure OnPaint(DC: HDC);
  11. var
  12.   graphics : TGPGraphics;
  13.   Pen: TGPPen;
  14. begin
  15.   graphics := TGPGraphics.Create(DC);
  16.   Pen := TGPPen.Create(MakeColor(255, 0, 0, 0),5);  // opaque green
  17.   graphics.SetSmoothingMode(SmoothingModeAntiAlias);
  18.   graphics.DrawEllipse(pen, 5, 5, 200, 100);
  19.   graphics.SetSmoothingMode(SmoothingModeHighSpeed);
  20.   graphics.DrawEllipse(pen, 5, 150, 200, 100);
  21.   Pen.Free;
  22.   graphics.Free;
  23. end;
  24.  
  25.  
  26. function WndProc(Wnd : HWND; message : UINT; wParam : Integer; lParam: Integer) : Integer; stdcall;
  27. var
  28.   Handle: HDC;
  29.   ps: PAINTSTRUCT;
  30. begin
  31.   case message of
  32.     WM_PAINT:
  33.       begin
  34.         Handle := BeginPaint(Wnd, ps);
  35.         OnPaint(Handle);
  36.         EndPaint(Wnd, ps);
  37.         result := 0;
  38.       end;
  39.  
  40.     WM_DESTROY:
  41.       begin
  42.         PostQuitMessage(0);
  43.         result := 0;
  44.       end;
  45.  
  46.    else
  47.       result := DefWindowProc(Wnd, message, wParam, lParam);
  48.    end;
  49. end;
  50.  
  51. var
  52.   hWnd     : THandle;
  53.   Msg      : TMsg;
  54.   wndClass : TWndClass;
  55. begin
  56.    wndClass.style          := CS_HREDRAW or CS_VREDRAW;
  57.    wndClass.lpfnWndProc    := @WndProc;
  58.    wndClass.cbClsExtra     := 0;
  59.    wndClass.cbWndExtra     := 0;
  60.    wndClass.hInstance      := hInstance;
  61.    wndClass.hIcon          := LoadIcon(0, IDI_APPLICATION);
  62.    wndClass.hCursor        := LoadCursor(0, IDC_ARROW);
  63.    wndClass.hbrBackground  := HBRUSH(GetStockObject(WHITE_BRUSH));
  64.    wndClass.lpszMenuName   := nil;
  65.    wndClass.lpszClassName  := 'GettingStarted';
  66.  
  67.    RegisterClass(wndClass);
  68.  
  69.    hWnd := CreateWindow(
  70.       'GettingStarted',       // window class name
  71.       'Quality Settings',      // window caption
  72.       WS_OVERLAPPEDWINDOW,    // window style
  73.       Integer(CW_USEDEFAULT), // initial x position
  74.       Integer(CW_USEDEFAULT), // initial y position
  75.       Integer(CW_USEDEFAULT), // initial x size
  76.       Integer(CW_USEDEFAULT), // initial y size
  77.       0,                      // parent window handle
  78.       0,                      // window menu handle
  79.       hInstance,              // program instance handle
  80.       nil);                   // creation parameters
  81.  
  82.    ShowWindow(hWnd, SW_SHOW);
  83.    UpdateWindow(hWnd);
  84.  
  85.    while(GetMessage(msg, 0, 0, 0)) do
  86.    begin
  87.       TranslateMessage(msg);
  88.       DispatchMessage(msg);
  89.    end;
  90. end.
  91.